"""
Models for the Bot application.
"""

from django.db import models

from track.models import Vehicle

# The models of the "TestBot" application

class Position(models.Model):
  """A log of positions that can be replayed. Mostly compatible with track.models.Position."""
  vehicle = models.ForeignKey(Vehicle, related_name="testbot_position")
  time    = models.PositiveIntegerField()
  x       = models.FloatField()
  y       = models.FloatField()
  
  def __unicode__(self):
    return '%(time)s - %(vehicle)s (%(x)s, %(y)s)'%{'vehicle': self.vehicle.name, 'x': self.x, 'y': self.y, 'time': self.time}
  
  class Meta:
    ordering = ['time']
  
  class Admin:
    list_filter   = ('vehicle', 'time')
    search_fields = ('vehicle__name', 'vehicle__slug')
  
